<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="util.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'add.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
    <style type="text/css">
    table{position:absolute;left:400px;top:150px;}
    .input{width:180px}
    </style>
  </head>
  
  <body background="img/4561.jpg">
    <form name="form1" action="doAddServlet" method="post">
      <input type="hidden" name="<%=PreventRefresh.TOKENNAME %>" value="<%=PreventRefresh.getTime(request) %>"/>
      <table align="center" border="2" bordercolor="pink">
         <tr>
           <td align="center" colspan="2">
             <font color="purple">添加成员</font>
           </td>
         </tr>
         <tr>
           <td align="center">
             <font color="purple">学生姓名</font>
           </td>
           <td align="center">
             <input type="text" class="input" name="stuName" value=""/>
           </td>
         </tr>
         <tr>
           <td align="center">
             <font color="purple">学生性别</font>
           </td>
           <td align="center">
                                      男<input type="radio" name="stuSex" value="男" checked/>
                                      女<input type="radio" name="stuSex" value="女"/>
           </td>
         </tr>
         <tr>
           <td align="center">
             <font color="purple">出生年月</font>
           </td>
           <td>
            <select id="year" name="year" onchange="getDays();">
             <option selected value="">-年份-</option>
             <option value="1985">1985</option>
             <option value="1986">1986</option>
             <option value="1987">1987</option>
             <option value="1988">1988</option>
             <option value="1989">1989</option>
             <option value="1990">1990</option>
             <option value="1991">1991</option>
             <option value="1992">1992</option>
             <option value="1993">1993</option>
             <option value="1994">1994</option>
             <option value="1995">1995</option>
            </select>
            <select id="month" name="month" onchange="getDays();">
             <option selected value="">-月份-</option>
             <option value="01">01</option>
             <option value="02">02</option>
             <option value="03">03</option>
             <option value="04">04</option>
             <option value="05">05</option>
             <option value="06">06</option>
             <option value="07">07</option>
             <option value="08">08</option>
             <option value="09">09</option>
             <option value="10">10</option>
             <option value="11">11</option>
             <option value="12">12</option>
            </select>
            <select id="day" name="day">
             <option selected value="">-日期-</option>
            </select>
          </td>
         </tr>
         <tr>
           <td align="center" colspan="2">
              <input type="reset" name="rs" value="重置">
              <input type="submit" name="sb" value="提交" onclick="return examine()">
              <a href="doShowList">点此返回</a>
           </td>
         </tr>
      </table>
    </form>
  </body>
  <script type="text/javascript">
  function getDays(){
	  var month=document.getElementById("month");
	  var n=document.getElementById("year").value;
	  var m=document.getElementById("month").value;
	  var day=document.getElementById("day");
	  var total=31;
	  if(""!=n&&""!=m){
		  if(m==2){
			  if(n%4==0&&n%100!=0){
				  total=29;
			  }else{
				  if(n%4==0&&n%100==0&&n%400==0){
					 total=29; 
				  }else{
					  total=28;
				  }
			  }
		  }else{
			  if(m==04||m==06||m==09||m==11){
				  total=30;
			  }
		  }
		  for(var i=1;i<=total;i++){
			  var op=new Option(i);
			  op.value=i;
			  day.add(op);
		  }
	  }
  }
  
  function examine(){
	  var stuname=document.getElementById("stuName").value;
	  var n=document.getElementById("year").value;
	  var m=document.getElementById("month").value;
	  var d=document.getElementById("day").value;
	  if(""==stuname){
		  alert("请输入姓名!");
		  return false;
	  }else{
		  if(""==n||""==m||""==d){
			  alert("请将出生信息填写完整!");
			  return false;
		  }else{
			  alert("添加成功!");
			  return true;
		  }
	  }
  }
  </script>
</html>
